﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace EncryptAlgoParameter
{
    public partial class frmMain : Form
    {
        public frmMain()
        {
            InitializeComponent();
        }

        private void btn_process_Click(object sender, EventArgs e)
        {
            ClsEncryptData data = new ClsEncryptData();
            data.Add("passPhrase", "P@s5pr@se");
            data.Add("saltValue", "s@1tV@1ue");
            data.Add("hashAlgorithm", "MD5");
            data.Add("initVector", "@1B2c3D4e5F6g7H8");
            tb_result.Text = data.ToString();
        }

        private void btn_decrypt_Click(object sender, EventArgs e)
        {
            ClsEncryptData data = new ClsEncryptData(tb_result.Text.Trim());
            string passPhrase = data["passPhrase"].ToString();
            string saltValue = data["saltValue"].ToString();
            string hashAlgorithm = data["hashAlgorithm"].ToString();
            string initVector = data["initVector"].ToString();

            string s = "";
            s += "passPhrase:" + passPhrase;
            s += "\r\n" + "saltValue:" + saltValue;
            s += "\r\n" + "hashAlgorithm:" + hashAlgorithm;
            s += "\r\n" + "initVector:" + initVector;
            MessageBox.Show(s);
        }

        private void btn_encrypt_smtp_pw_Click(object sender, EventArgs e)
        {
            ClsEncryptData data = new ClsEncryptData();
            data.Add("SmtpPassword", tb_password.Text.Trim());
            tb_smtp.Text = data.ToString();
        }

        private void btn_decrypt_smtp_pw_Click(object sender, EventArgs e)
        {
            ClsEncryptData data = new ClsEncryptData(tb_smtp.Text.Trim());
            MessageBox.Show(data["SmtpPassword"].ToString());
        }
    }
}
